package traveler.controllers;

import traveler.activities.CourseAddActivity;
import traveler.activities.SocialActivity;
import traveler.tools.ExtendedAlertDialog;
import traveler.tools.Tools;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class DashboardController extends BaseController implements
		View.OnClickListener, OnClickListener {
	public DashboardController(Activity activity) {
		super(activity);
	}

	public void onClick(DialogInterface d, int which) {
		Log.d("DC::onClick(d,w)", "START");
		
		Intent intent = null;
		
		switch (Tools.getInstance().classNameToInt(d.getClass().toString())) {
		case Tools.ALERTDIALOG:
			AlertDialog ead = (AlertDialog) d;
			
			Log.d("DC::onClick(d,w)", "START - " + which);
			switch (which) {
			case 0:
				Log.d("DC::onClick(d,w)", "PHOTO");
				_activity.startActivityForResult(Intent.createChooser(new Intent().setType("image/*").setAction(Intent.ACTION_GET_CONTENT), "Gallery"), 0);
				break;
			case 1:
				Log.d("DC::onClick(d,w)", "COMMENT");
				intent = new Intent(_activity, SocialActivity.class);
				break;
			case 2:
				Log.d("DC::onClick(d,w)", "COURSE - ");
				intent = new Intent(_activity, CourseAddActivity.class);
				break;
			case 3:
				Log.d("DC::onClick(d,w)", "FACEBOOK");

				break;

			default:
				Log.e("DC::onClick(d,w)", "UNMANAGED ExtendedAlertDialog");
				ead.cancel();
				break;
			}
			break;

		default:
			Log.e("DC::onClick(d,w)", "UNMANAGED dialog");
			d.cancel();
			break;
		}
		
		if(intent != null)
			_activity.startActivity(intent);

		Log.d("DC::onClick(d,w)", "END");

	}

	
	public void onClick(View v) {
		// TODO Auto-generated method stub

	}
}